import { ApiProperty } from "@nestjs/swagger";
import { IsNotEmpty, IsString, Length } from "class-validator";
import { CourseEnum } from "src/enums/school/course.enum";
import { TeacherTitleEnum } from "src/enums/school/teacher.enum";
import { IsIdCard, IsPhone } from "src/utils/rules";

export class CreateTeacherDto {
  @ApiProperty({ title: "教师名称", required: true })
  @IsNotEmpty({ message: "教师名称不能为空" })
  @IsString()
  teacherName: string;

  @ApiProperty({ title: "教师职称", required: true })
  @IsNotEmpty({ message: "教师职称不能为空" })
  @IsString()
  teacherTitle: keyof typeof TeacherTitleEnum; // 获取枚举的 value 作为类型

  @ApiProperty({ title: "课程", required: true })
  @IsNotEmpty({ message: "课程不能为空" })
  @IsString()
  course: `${CourseEnum}`; // 获取枚举的 value 作为类型

  @ApiProperty({ title: "性别", required: true })
  @IsNotEmpty({ message: "性别不能为空" })
  gender: 1 | 2 | 3; // 教师性别 1-男 2-女 3-未知

  @ApiProperty({ title: "简介", required: true })
  @IsNotEmpty({ message: "简介不能为空" })
  @IsString()
  teacherProfile: string;

  @ApiProperty({ title: "联系电话", required: true })
  @IsNotEmpty({ message: "联系电话不能为空" })
  @IsString()
  @Length(11, 11, { message: "联系电话长度错误" })
  @IsPhone("teacherPhone", { message: "联系电话格式错误" })
  teacherPhone: string;

  @ApiProperty({ title: "教师照片", required: false })
  teacherPhoto: string;

  @ApiProperty({ title: "现居地址", required: true })
  @IsNotEmpty({ message: "现居地址不能为空" })
  @IsString()
  currentAddress: string;

  @ApiProperty({ title: "身份证号码", required: true })
  @IsNotEmpty({ message: "身份证号码不能为空" })
  @IsString()
  @Length(18, 18, { message: "身份证号码长度错误" })
  @IsIdCard("idCard", { message: "身份证号码格式错误" })
  idCard: string;

  @ApiProperty({ title: "身份证地址", required: true })
  @IsNotEmpty({ message: "身份证地址不能为空" })
  @IsString()
  idCardAddress: string;

  @ApiProperty({ title: "生日", required: true })
  @IsNotEmpty({ message: "生日不能为空" })
  @IsString()
  birthday: string;

  createBy: string; 
  createById: number;
  updateBy: string;
  updateById: number;
}
